﻿var scene, camera, renderer;
var light, controls;
var lastTime;
function start() {
    init();
    animate();
}
function init() {
    
    renderer = new THREE.WebGLRenderer( { antialias: false, alpha: false } );
    renderer.setClearColor( 0xd8e7ff );
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 3000 );
    camera.position.y = 80;

    controls = new THREE.FirstPersonControls( camera );
    controls.movementSpeed = 20;
    controls.lookSpeed = 0.05;
    controls.lookVertical = true;
   
    scene = new THREE.Scene();
    scene.fog = new THREE.FogExp2( 0xd0e0f0, 0.0025 );

    light = new THREE.HemisphereLight( 0xfffff0, 0x101020, 1.25 );
    light.position.set( 0.75, 1, 0.25 );
    scene.add( light );

    var plane = new THREE.Mesh( new THREE.PlaneGeometry( 3000, 3000 ), new THREE.MeshBasicMaterial( { color: 006400 } ) );
    plane.rotation.x = - 90 * Math.PI / 180;
    scene.add( plane );



    lastTime = performance.now();

}



function animate() {

    requestAnimationFrame( animate );

    var time = performance.now() / 1000;

    controls.update( time - lastTime );
    renderer.render( scene, camera );

    lastTime = time;

}

